//
//  WikipediaDetailViewController.m
//  SYiDaiy
//
//  Created by dllo on 16/9/3.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "WikipediaDetailViewController.h"
#import "TAMacro.h"
#import "CustomWebview.h"
@interface WikipediaDetailViewController ()<UITableViewDataSource,UITableViewDelegate,UICollectionViewDataSource>
@property (nonatomic,strong) UITableView *wikipedDetailTableView;

@property (nonatomic,strong) CustomWebview *webView;

@end

@implementation WikipediaDetailViewController
#pragma mark -----视图加载
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    
    
    UICollectionViewFlowLayout *flow = [UICollectionViewFlowLayout new];
    [flow setScrollDirection:UICollectionViewScrollDirectionHorizontal];

    CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64 - 49);
    UICollectionView *wikipedCollection = [[UICollectionView alloc] initWithFrame:rect collectionViewLayout:flow];
    
//    wikipedCollection.dataSource = self;

    CGPoint point = CGPointMake(SCREEN_WIDTH * _rowValue, 44);
    [wikipedCollection setContentOffset:point];
    
    UIColor *white = [UIColor whiteColor];
    [wikipedCollection setBackgroundColor:white];
    [wikipedCollection setPagingEnabled:YES];
    CGSize size = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT - 49 - 64);
    [flow setItemSize:size];
    [flow setMinimumInteritemSpacing:0];
    [flow setMinimumLineSpacing:0];
    UIEdgeInsets inset = UIEdgeInsetsMake(0, 0, 0, 0);
    [flow setSectionInset:inset];
    
    
    
    [wikipedCollection setDataSource:self];
    
    [[self view]addSubview:wikipedCollection];
    
    Class class   = [UICollectionViewCell class];
    [wikipedCollection registerClass:class forCellWithReuseIdentifier:@"wikipedCollectionCell"];
}
#pragma mark ----集合视图返回cell的方法
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"wikipedCollectionCell" forIndexPath:indexPath];

    NSInteger row = [indexPath row];
    Wikipediaesarray *wikipediaesarray = [_wikipedArray objectAtIndex:row];
    NSString *link_share = [wikipediaesarray link_share];
    _webView = [CustomWebview new];
    
    CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 49 - 64);
    [_webView setFrame:rect];
    [_webView passStr:link_share];

    [cell addSubview:_webView];
    return cell;
}
#pragma mark ----collection返回item的个数
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 2;
}


//#pragma mark ------tableview返回cell的方法
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    UITableViewCell *cell = [tableView  dequeueReusableCellWithIdentifier:@"wikipedTableViewCell"];
//   UIColor *purple = [UIColor purpleColor];
//   [cell setBackgroundColor:purple];
//    CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH, 1000);
//    UILabel *label = [[UILabel alloc] initWithFrame:rect];
//    label.backgroundColor = [UIColor greenColor];
//
//    [cell addSubview:label];
//    
//    NSURL *url = [NSURL URLWithString:_link_share];
//    
//    NSString *str = url.absoluteString;
//    
//    
//    
//    label.text = str;
//
//    
//    
//    
//
//    
//    
//    
//    
//    
//    
//    return cell;
//    
//}

//#pragma mark ------tableview的item的个数
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//{
//    return 1;
//}
//#pragma mark ------返回row的高度
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    return 1000;
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
